home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / COMMON / TOOLS / VB / CABINETS / MSDAO350.CAB / icontrols / DataList / DataList.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-01-08  |  19.1 KB  |  731 lines

  1. package icontrols.DataList;
  2.  
  3. import com.ms.ado.AdoException;
  4. import com.ms.ado.DataSource;
  5. import com.ms.ado.Field;
  6. import com.ms.ado.Recordset;
  7. import com.ms.ado.RecordsetEvent;
  8. import com.ms.wd.app.Message;
  9. import com.ms.wd.core.CancelEvent;
  10. import com.ms.wd.core.Closure;
  11. import com.ms.wd.core.Event;
  12. import com.ms.wd.core.EventHandler;
  13. import com.ms.wd.core.Sys;
  14. import com.ms.wd.ui.Color;
  15. import com.ms.wd.ui.Control;
  16. import com.ms.wd.ui.Font;
  17. import com.ms.wd.ui.Graphics;
  18. import com.ms.wd.ui.MouseEvent;
  19. import com.ms.wd.ui.PaintEvent;
  20. import com.ms.wd.ui.Pen;
  21. import com.ms.wd.ui.Rectangle;
  22. import com.ms.wd.ui.ScrollBar;
  23. import com.ms.wd.ui.ScrollEvent;
  24. import com.ms.wd.ui.ScrollEventHandler;
  25. import com.ms.wd.ui.VScrollBar;
  26. import com.ms.wd.util.Debug;
  27. import com.ms.wd.util.Utils;
  28. import com.ms.wd.win32.RECT;
  29. import com.ms.wd.win32.TEXTMETRIC;
  30. import com.ms.wd.win32.Windows;
  31. import icontrols.BorderDisplayer;
  32. import icontrols.StringDisplayer;
  33. import icontrols.Data.DataProvider;
  34. import icontrols.Data.DataRow;
  35. import icontrols.Data.IDataConsumer;
  36. import icontrols.Data.RecordsetProvider;
  37.  
  38. public class DataList extends Control implements IDataConsumer {
  39.    private EventHandler valueChanged = null;
  40.    private DataProvider dataProvider = null;
  41.    private Recordset lookupList = null;
  42.    private String boundColumn = null;
  43.    private String listColumn = null;
  44.    private ScrollBar scrollbar = new VScrollBar();
  45.    private Rectangle clientRect = null;
  46.    private Rectangle clientInsideRect = null;
  47.    private BorderDisplayer borderDisplayer = new BorderDisplayer();
  48.    private StringDisplayer stringDisplayer = new StringDisplayer();
  49.    private StringDisplayer stringSelectedDisplayer = new StringDisplayer();
  50.    private int borderStyle = 2;
  51.    private Field boundField = null;
  52.    private Field listField = null;
  53.    private Field lookupListField = null;
  54.    private int rowHeight = -1;
  55.    private DataRow selectedRow = null;
  56.    private DataRow hotTrack = null;
  57.    private boolean trackSelection = false;
  58.    private RecordsetProvider recordsetProvider = new RecordsetProvider();
  59.    // $FF: synthetic field
  60.    private static Class class$icontrols$DataList$BorderStyle;
  61.  
  62.    public void setListColumn(String listColumn) {
  63.       if (!Utils.stringsEqual(listColumn, this.listColumn)) {
  64.          this.listColumn = listColumn;
  65.          this.bindToDisplayFields();
  66.          ((Control)this).invalidate();
  67.       }
  68.  
  69.    }
  70.  
  71.    public void onWillChangeFieldHandler(Object sender, RecordsetEvent event) {
  72.    }
  73.  
  74.    public void onWillChangeRecordHandler(Object sender, RecordsetEvent event) {
  75.    }
  76.  
  77.    public void onMouseMove(MouseEvent me) {
  78.       if (this.dataProvider != null && this.listField != null && this.boundField != null) {
  79.          int displayIndex = this.getDisplayIndexFromY(me.y);
  80.          if (displayIndex >= 0) {
  81.             if (!this.trackSelection) {
  82.                this.setHotTrackRow(this.dataProvider.getDisplayRow(displayIndex));
  83.             } else {
  84.                this.setHotTrackRow((DataRow)null);
  85.                this.setSelectedRow(this.dataProvider.getDisplayRow(displayIndex));
  86.             }
  87.          }
  88.  
  89.          super.onMouseMove(me);
  90.       }
  91.    }
  92.  
  93.    public DataSource getRowSource() {
  94.       return this.recordsetProvider.getDataSource();
  95.    }
  96.  
  97.    protected boolean isHandleOwnedByList(int hwnd) {
  98.       return hwnd == ((Control)this).getHandle() || hwnd == this.scrollbar.getHandle();
  99.    }
  100.  
  101.    public void setRowSource(DataSource dataSource) {
  102.       this.recordsetProvider.setDataSource(dataSource);
  103.    }
  104.  
  105.    private Rectangle getRowBounds(int displayIndex) {
  106.       int height = this.getRowHeight();
  107.       Rectangle inside = this.getCachedClientInsideRect();
  108.       return new Rectangle(inside.x, inside.y + height * displayIndex, inside.width, height);
  109.    }
  110.  
  111.    private int getDisplayIndexFromY(int y) {
  112.       Rectangle inside = this.getCachedClientInsideRect();
  113.       int displayIndex = -1;
  114.       if (y > inside.y && y < inside.y + inside.height) {
  115.          y -= inside.y;
  116.          displayIndex = y / this.getRowHeight();
  117.       }
  118.  
  119.       return displayIndex;
  120.    }
  121.  
  122.    public void acquireRecordset(Object sender, Event event) {
  123.       this.dataProvider = new DataProvider(this.recordsetProvider.getRecordset());
  124.       this.dataProvider.setDataConsumer(this);
  125.       this.lookupList = (Recordset)this.recordsetProvider.getRecordset().clone();
  126.       this.bindToDisplayFields();
  127.       this.doLayout();
  128.       ((Control)this).invalidate();
  129.    }
  130.  
  131.    public void releaseRecordset(Object sender, Event event) {
  132.       if (this.dataProvider != null) {
  133.          this.dataProvider.setDataConsumer((IDataConsumer)null);
  134.          this.dataProvider = null;
  135.          this.lookupList = null;
  136.          this.boundField = null;
  137.          this.listField = null;
  138.          this.lookupListField = null;
  139.       }
  140.  
  141.    }
  142.  
  143.    private Rectangle getCachedClientInsideRect() {
  144.       if (this.clientRect == null) {
  145.          Rectangle junk = this.getCachedClientRect();
  146.       }
  147.  
  148.       Debug.assert(this.clientInsideRect != null, "Null client inside rect");
  149.       return this.clientInsideRect;
  150.    }
  151.  
  152.    public String getDisplayData(int displayIndex) {
  153.       Debug.assert(this.dataProvider != null, "null dataprovider");
  154.       Debug.assert(this.lookupList != null, "null lookuplist");
  155.       Debug.assert(this.boundField != null, "null bound field");
  156.       Debug.assert(this.listField != null, "null list field");
  157.       Debug.assert(this.lookupListField != null, "null lookup list field");
  158.       Debug.assert(Utils.stringsEqual(this.boundField.getName(), this.boundColumn) && this.boundColumn != null, "invalid bound field info");
  159.       DataRow row = this.dataProvider.getDisplayRow(displayIndex);
  160.       String rawData = this.dataProvider.getFormattedData(row, this.boundField);
  161.       this.lookupList.setFilter(this.boundColumn + " = " + rawData);
  162.       this.lookupList.moveFirst();
  163.       return this.lookupListField.getString();
  164.    }
  165.  
  166.    public String getDisplayData(String value) {
  167.       Debug.assert(this.dataProvider != null, "null dataprovider");
  168.       Debug.assert(this.lookupList != null, "null lookuplist");
  169.       Debug.assert(this.boundField != null, "null bound field");
  170.       Debug.assert(this.listField != null, "null list field");
  171.       Debug.assert(this.lookupListField != null, "null lookup list field");
  172.       Debug.assert(Utils.stringsEqual(this.boundField.getName(), this.boundColumn) && this.boundColumn != null, "invalid bound field info");
  173.       this.lookupList.setFilter(this.boundColumn + " = " + value);
  174.       this.lookupList.moveFirst();
  175.       return this.lookupListField.getString();
  176.    }
  177.  
  178.    public void onMouseLeave(MouseEvent me) {
  179.       this.setHotTrackRow((DataRow)null);
  180.       super.onMouseLeave(me);
  181.    }
  182.  
  183.    public void onFieldChangeCompleteHandler(Object sender, RecordsetEvent event) {
  184.    }
  185.  
  186.    public void onRecordChangeCompleteHandler(Object sender, RecordsetEvent event) {
  187.    }
  188.  
  189.    public void addValueChangedHandler(EventHandler handler) {
  190.       this.valueChanged = (EventHandler)Closure.combine(this.valueChanged, handler);
  191.    }
  192.  
  193.    public String getBoundColumn() {
  194.       return this.boundColumn;
  195.    }
  196.  
  197.    public void setAsyncPostMessage(int message) {
  198.    }
  199.  
  200.    public void onMoveCompleteHandler(Object sender, RecordsetEvent event) {
  201.       DataRow old = this.selectedRow;
  202.       this.selectedRow = this.dataProvider.getCurrentRow();
  203.       this.dataProvider.scrollCurrentIntoView();
  204.       this.invalidateRow(old);
  205.       this.invalidateRow(this.selectedRow);
  206.       if (!this.trackSelection) {
  207.          this.onValueChanged(Event.EMPTY);
  208.       }
  209.  
  210.    }
  211.  
  212.    public void onRecordsetChangeCompleteHandler(Object sender, RecordsetEvent event) {
  213.    }
  214.  
  215.    private int computePageSize() {
  216.       int height = this.getRowHeight();
  217.       return (this.getCachedClientInsideRect().height + 2 * height - 1) / height;
  218.    }
  219.  
  220.    private void bindToDisplayFields() {
  221.       if (this.boundColumn != null && this.dataProvider != null) {
  222.          this.boundField = this.dataProvider.getReadField(this.boundColumn);
  223.       } else {
  224.          this.boundField = null;
  225.       }
  226.  
  227.       if (this.listColumn != null && this.dataProvider != null) {
  228.          this.listField = this.dataProvider.getReadField(this.listColumn);
  229.       } else {
  230.          this.listField = null;
  231.       }
  232.  
  233.       if (this.listField == null && this.boundField != null) {
  234.          this.listField = this.boundField;
  235.       }
  236.  
  237.       if (this.boundField == null && this.listField != null) {
  238.          this.boundField = this.listField;
  239.       }
  240.  
  241.       if (this.listField != null) {
  242.          this.lookupListField = this.lookupList.getFields().getItem(this.listField.getName());
  243.       }
  244.  
  245.    }
  246.  
  247.    private void doLayout() {
  248.       this.clientRect = null;
  249.       Rectangle inside = this.getCachedClientInsideRect();
  250.       Rectangle bounds = this.scrollbar.getBounds();
  251.       bounds.x = inside.x + inside.width;
  252.       bounds.y = inside.y;
  253.       bounds.height = inside.height;
  254.       this.scrollbar.setBounds(bounds);
  255.       this.scrollbar.setEnabled(this.dataProvider != null);
  256.       if (this.dataProvider != null) {
  257.          this.dataProvider.setPageSize(this.computePageSize());
  258.       }
  259.  
  260.       this.updateVertScrollbar();
  261.    }
  262.  
  263.    public int getAsyncPostHwnd() {
  264.       return 0;
  265.    }
  266.  
  267.    public void setBoundColumn(String boundColumn) {
  268.       if (!Utils.stringsEqual(boundColumn, this.boundColumn)) {
  269.          this.boundColumn = boundColumn;
  270.          this.bindToDisplayFields();
  271.          this.doLayout();
  272.          ((Control)this).invalidate();
  273.       }
  274.  
  275.    }
  276.  
  277.    protected void onResize(Event e) {
  278.       if (this.clientRect != null) {
  279.          int borderWidth = this.borderDisplayer.getBorderWidth();
  280.          int borderHeight = this.borderDisplayer.getBorderHeight();
  281.          Rectangle right = null;
  282.          Rectangle bottom = null;
  283.          right = new Rectangle(this.clientRect.x + this.clientRect.width - borderWidth, this.clientRect.y, borderWidth, this.clientRect.height);
  284.          bottom = new Rectangle(this.clientRect.x, this.clientRect.y + this.clientRect.height - borderHeight, this.clientRect.width, borderHeight);
  285.          Rectangle newClientRect = ((Control)this).getClientRect();
  286.          if (newClientRect.width != this.clientRect.width) {
  287.             ((Control)this).invalidateRect(right);
  288.             right = new Rectangle(newClientRect.x + newClientRect.width - borderWidth, newClientRect.y, borderWidth, newClientRect.height);
  289.             ((Control)this).invalidateRect(right);
  290.          }
  291.  
  292.          if (newClientRect.height != this.clientRect.height) {
  293.             ((Control)this).invalidateRect(bottom);
  294.             bottom = new Rectangle(newClientRect.x, newClientRect.y + newClientRect.height - borderHeight, newClientRect.width, borderHeight);
  295.             ((Control)this).invalidateRect(bottom);
  296.          }
  297.       }
  298.  
  299.       super.onResize(e);
  300.       this.doLayout();
  301.    }
  302.  
  303.    private void updateVertScrollbar() {
  304.       if (this.dataProvider != null) {
  305.          int pageSize = this.dataProvider.getPageSize();
  306.          int totalSize = this.dataProvider.getTotalRowCount();
  307.          float currentRatio = this.dataProvider.getTopRowRatio();
  308.          if (totalSize > pageSize) {
  309.             this.scrollbar.setValues(0, totalSize, 1, pageSize, (int)(currentRatio * (float)totalSize));
  310.          } else {
  311.             this.scrollbar.setValues(0, 1, 1, 1, 0);
  312.          }
  313.       }
  314.  
  315.    }
  316.  
  317.    private int getRowHeight() {
  318.       if (this.rowHeight < 0) {
  319.          this.setRowHeight(this.computeRowHeight());
  320.       }
  321.  
  322.       return this.rowHeight;
  323.    }
  324.  
  325.    private void setRowHeight(int rowHeight) {
  326.       if (rowHeight != this.rowHeight) {
  327.          this.rowHeight = rowHeight;
  328.          this.doLayout();
  329.          ((Control)this).invalidate();
  330.       }
  331.  
  332.    }
  333.  
  334.    protected void setTrackSelection(boolean selecting) {
  335.       this.trackSelection = selecting;
  336.    }
  337.  
  338.    private void setSelectedRow(DataRow row) {
  339.       if (row != null) {
  340.          if (!DataProvider.rowsEqual(row, this.selectedRow)) {
  341.             this.dataProvider.setCurrentRow(row.getBookmark());
  342.             this.dataProvider.scrollCurrentIntoView();
  343.             DataRow old = this.selectedRow;
  344.             this.selectedRow = this.dataProvider.getCurrentRow();
  345.             this.invalidateRow(old);
  346.             this.invalidateRow(this.selectedRow);
  347.          }
  348.       } else if (this.selectedRow != null) {
  349.          DataRow old = this.selectedRow;
  350.          this.selectedRow = null;
  351.          this.invalidateRow(old);
  352.          if (!this.trackSelection) {
  353.             this.onValueChanged(Event.EMPTY);
  354.          }
  355.       }
  356.  
  357.    }
  358.  
  359.    public String getValue() {
  360.       String ret = null;
  361.       if (this.selectedRow != null && this.dataProvider != null && this.boundField != null) {
  362.          ret = this.dataProvider.getFormattedData(this.selectedRow, this.boundField);
  363.       }
  364.  
  365.       return ret;
  366.    }
  367.  
  368.    protected void propertyChanged(int property) {
  369.       switch (property) {
  370.          case 6:
  371.             this.setRowHeight(this.computeRowHeight());
  372.          default:
  373.             super.propertyChanged(property);
  374.       }
  375.    }
  376.  
  377.    public void setValue(String value) {
  378.       if (!Utils.stringsEqual(this.getValue(), value)) {
  379.          if (value == null) {
  380.             this.setSelectedRow((DataRow)null);
  381.          } else {
  382.             Debug.assert(this.dataProvider != null, "null dataprovider");
  383.             Debug.assert(this.lookupList != null, "null lookuplist");
  384.             Debug.assert(this.boundField != null, "null bound field");
  385.             Debug.assert(Utils.stringsEqual(this.boundField.getName(), this.boundColumn) && this.boundColumn != null, "invalid bound field info");
  386.             this.lookupList.setFilter(this.boundColumn + " = " + value);
  387.             Object bookmark = null;
  388.  
  389.             try {
  390.                this.lookupList.moveFirst();
  391.                bookmark = this.lookupList.getBookmark();
  392.             } catch (Exception var4) {
  393.                bookmark = null;
  394.             }
  395.  
  396.             if (bookmark != null) {
  397.                this.dataProvider.setCurrentRow(bookmark);
  398.                this.dataProvider.scrollCurrentIntoView();
  399.                DataRow old = this.selectedRow;
  400.                this.selectedRow = this.dataProvider.getCurrentRow();
  401.                this.invalidateRow(old);
  402.                this.invalidateRow(this.selectedRow);
  403.             }
  404.          }
  405.       }
  406.  
  407.    }
  408.  
  409.    public DataList() {
  410.       ((Control)this).setBackColor(Color.WINDOW);
  411.       this.recordsetProvider.setOnAcquireRecordset(new EventHandler(this, "acquireRecordset"));
  412.       this.recordsetProvider.setOnReleaseRecordset(new EventHandler(this, "releaseRecordset"));
  413.       this.stringDisplayer.setFont((Font)null);
  414.       this.stringDisplayer.setBackColor((Color)null);
  415.       this.stringDisplayer.setForeColor((Color)null);
  416.       this.stringDisplayer.setAlignment(5);
  417.       this.stringSelectedDisplayer.setBackColor(Color.HIGHLIGHT);
  418.       this.stringSelectedDisplayer.setForeColor(Color.HIGHLIGHTTEXT);
  419.       this.stringSelectedDisplayer.setAlignment(5);
  420.       this.setupBorder();
  421.       ((Control)this).add(this.scrollbar);
  422.       this.scrollbar.setVisible(true);
  423.       this.scrollbar.addOnScroll(new ScrollEventHandler(this, "onVertScroll"));
  424.       ((Control)this).setBounds(0, 0, 121, 121);
  425.       this.doLayout();
  426.    }
  427.  
  428.    public void onViewScrolled(boolean offsetValid, int offset) {
  429.       ((Control)this).invalidate();
  430.    }
  431.  
  432.    public void onMouseUp(MouseEvent me) {
  433.       if (this.dataProvider != null && this.listField != null && this.boundField != null) {
  434.          this.trackSelection = false;
  435.          ((Control)this).setCapture(false);
  436.          this.onValueChanged(Event.EMPTY);
  437.          super.onMouseUp(me);
  438.       }
  439.    }
  440.  
  441.    public void onEndOfRecordsetHandler(Object sender, RecordsetEvent event) {
  442.    }
  443.  
  444.    public void onWillChangeRecordsetHandler(Object sender, RecordsetEvent event) {
  445.    }
  446.  
  447.    public void onWillMoveHandler(Object sender, RecordsetEvent event) {
  448.    }
  449.  
  450.    public String getRowMember() {
  451.       return this.recordsetProvider.getDataMember();
  452.    }
  453.  
  454.    public void removeValueChangedHandler(EventHandler handler) {
  455.       this.valueChanged = (EventHandler)Closure.remove(this.valueChanged, handler);
  456.    }
  457.  
  458.    public void setRowMember(String dataMember) {
  459.       this.recordsetProvider.setDataMember(dataMember);
  460.    }
  461.  
  462.    protected void wndProc(Message m) {
  463.       boolean callDefault = true;
  464.       switch (m.msg) {
  465.          case 20:
  466.             callDefault = false;
  467.             break;
  468.          case 135:
  469.             callDefault = false;
  470.             m.result = 0;
  471.             m.result |= 1;
  472.       }
  473.  
  474.       if (callDefault) {
  475.          super.wndProc(m);
  476.       }
  477.  
  478.    }
  479.  
  480.    protected void onValueChanged(Event event) {
  481.       if (this.valueChanged != null) {
  482.          this.valueChanged.invoke(this, event);
  483.       }
  484.  
  485.    }
  486.  
  487.    public int getBorderStyle() {
  488.       return this.borderStyle;
  489.    }
  490.  
  491.    public void setBorderStyle(int borderStyle) {
  492.       if (this.borderStyle != borderStyle) {
  493.          if (borderStyle < 0 || borderStyle > 3) {
  494.             throw new IllegalArgumentException(Sys.getString("InvalidEnumArgument", "borderStyle", (new Integer(borderStyle)).toString(), (class$icontrols$DataList$BorderStyle != null ? class$icontrols$DataList$BorderStyle : (class$icontrols$DataList$BorderStyle = class$("icontrols.DataList.BorderStyle"))).getName()));
  495.          }
  496.  
  497.          this.borderStyle = borderStyle;
  498.          this.setupBorder();
  499.       }
  500.  
  501.    }
  502.  
  503.    // $FF: synthetic method
  504.    private static Class class$(String s) {
  505.       try {
  506.          return Class.forName(s);
  507.       } catch (ClassNotFoundException e) {
  508.          throw new NoClassDefFoundError(((Throwable)e).getMessage());
  509.       }
  510.    }
  511.  
  512.    public void onWillViewScroll(Object sender, CancelEvent cancel) {
  513.    }
  514.  
  515.    public void onVertScroll(Object sender, ScrollEvent se) {
  516.       se.useNewPos = false;
  517.       if (((Control)this).getEnabled()) {
  518.          boolean updateScrollbar = true;
  519.          DataRow current = this.dataProvider.getDisplayRow(0);
  520.          switch (se.type) {
  521.             case 0:
  522.                if (current != null) {
  523.                   this.dataProvider.scroll(-1, current.getBookmark());
  524.                } else {
  525.                   this.dataProvider.scrollToFirst();
  526.                }
  527.                break;
  528.             case 1:
  529.                if (current != null) {
  530.                   this.dataProvider.scroll(1, current.getBookmark());
  531.                } else {
  532.                   this.dataProvider.scrollToBottom();
  533.                }
  534.                break;
  535.             case 2:
  536.                if (current != null) {
  537.                   this.dataProvider.scroll(-1 * this.dataProvider.getPageSize(), current.getBookmark());
  538.                } else {
  539.                   this.dataProvider.scrollToFirst();
  540.                }
  541.                break;
  542.             case 3:
  543.                if (current != null) {
  544.                   this.dataProvider.scroll(this.dataProvider.getPageSize(), current.getBookmark());
  545.                } else {
  546.                   this.dataProvider.scrollToBottom();
  547.                }
  548.                break;
  549.             case 4:
  550.                int totalSize = this.dataProvider.getTotalRowCount();
  551.                this.dataProvider.scroll((float)se.newPos / (float)totalSize);
  552.                break;
  553.             case 5:
  554.                updateScrollbar = false;
  555.          }
  556.  
  557.          if (updateScrollbar) {
  558.             this.updateVertScrollbar();
  559.          }
  560.  
  561.       }
  562.    }
  563.  
  564.    private Rectangle getCachedClientRect() {
  565.       if (this.clientRect == null) {
  566.          int borderWidth = this.borderDisplayer.getBorderWidth();
  567.          int borderHeight = this.borderDisplayer.getBorderHeight();
  568.          Rectangle client = ((Control)this).getClientRect();
  569.          Rectangle inside = new Rectangle();
  570.          inside.x = client.x + borderWidth;
  571.          inside.y = client.y + borderHeight;
  572.          inside.width = client.width - 2 * borderWidth - this.scrollbar.getBounds().width;
  573.          inside.height = client.height - 2 * borderHeight;
  574.          this.clientInsideRect = inside;
  575.          this.clientRect = client;
  576.       }
  577.  
  578.       Debug.assert(this.clientRect != null, "Null client rect");
  579.       return this.clientRect;
  580.    }
  581.  
  582.    private int computeRowHeight() {
  583.       Graphics g = ((Control)this).createGraphics();
  584.       g.setFont(((Control)this).getFont());
  585.       TEXTMETRIC tm = new TEXTMETRIC();
  586.       Windows.GetTextMetrics(g.getHandle(), tm);
  587.       int height = tm.tmHeight + 4;
  588.       g.dispose();
  589.       return height;
  590.    }
  591.  
  592.    private void setupBorder() {
  593.       switch (this.borderStyle) {
  594.          case 0:
  595.             this.borderDisplayer.setBorderStyle(4);
  596.             break;
  597.          case 1:
  598.             this.borderDisplayer.setBorderStyle(1);
  599.             break;
  600.          case 2:
  601.             this.borderDisplayer.setBorderStyle(18);
  602.             break;
  603.          case 3:
  604.             this.borderDisplayer.setBorderStyle(34);
  605.       }
  606.  
  607.       this.doLayout();
  608.       ((Control)this).invalidate();
  609.    }
  610.  
  611.    public void onMouseDown(MouseEvent me) {
  612.       if (this.dataProvider != null && this.listField != null && this.boundField != null) {
  613.          this.trackSelection = true;
  614.          int displayIndex = this.getDisplayIndexFromY(me.y);
  615.          if (displayIndex >= 0) {
  616.             this.setSelectedRow(this.dataProvider.getDisplayRow(displayIndex));
  617.          }
  618.  
  619.          ((Control)this).setCapture(true);
  620.          super.onMouseDown(me);
  621.       }
  622.    }
  623.  
  624.    private void invalidateRow(DataRow row) {
  625.       if (row != null) {
  626.          DataRow rowLookup = this.dataProvider.getDisplayRow(row.getBookmark());
  627.          if (rowLookup != null) {
  628.             this.invalidateRow(rowLookup.getDisplayIndex());
  629.          }
  630.  
  631.       }
  632.    }
  633.  
  634.    private void invalidateRow(int displayIndex) {
  635.       if (displayIndex >= 0) {
  636.          Rectangle rect = this.getRowBounds(displayIndex);
  637.          if (rect != null) {
  638.             ((Control)this).invalidateRect(rect);
  639.             ((Control)this).update();
  640.          }
  641.  
  642.       }
  643.    }
  644.  
  645.    protected String selectByMatch(String value) {
  646.       if (this.dataProvider != null && this.lookupList != null && this.boundField != null && this.listField != null && this.lookupListField != null) {
  647.          this.lookupList.setFilter(this.listColumn + " LIKE '" + value + "%'");
  648.  
  649.          try {
  650.             this.lookupList.moveFirst();
  651.          } catch (AdoException var3) {
  652.          }
  653.  
  654.          if (!this.lookupList.getEOF() && !this.lookupList.getBOF()) {
  655.             this.dataProvider.setCurrentRow(this.lookupList.getBookmark());
  656.             return this.lookupListField.getString();
  657.          }
  658.       }
  659.  
  660.       return null;
  661.    }
  662.  
  663.    private void setHotTrackRow(DataRow row) {
  664.       if (row != null) {
  665.          if (!DataProvider.rowsEqual(row, this.hotTrack)) {
  666.             DataRow old = this.hotTrack;
  667.             this.hotTrack = row;
  668.             this.invalidateRow(old);
  669.             this.invalidateRow(this.hotTrack);
  670.          }
  671.       } else if (this.hotTrack != null) {
  672.          DataRow old = this.hotTrack;
  673.          this.hotTrack = null;
  674.          this.invalidateRow(old);
  675.       }
  676.  
  677.    }
  678.  
  679.    private void onNoRowsetPaint(PaintEvent pe) {
  680.       this.borderDisplayer.paintIn(pe.graphics, this.getCachedClientRect(), pe.clipRect);
  681.       pe.graphics.setPen((Pen)null);
  682.       pe.graphics.drawRect(this.getCachedClientInsideRect());
  683.    }
  684.  
  685.    protected void onPaint(PaintEvent pe) {
  686.       if (this.dataProvider != null && this.listField != null && this.boundField != null) {
  687.          Rectangle inside = this.getCachedClientInsideRect();
  688.          Rectangle client = this.getCachedClientRect();
  689.          this.borderDisplayer.paintIn(pe.graphics, client, pe.clipRect);
  690.          pe.graphics.intersectClipRect(inside);
  691.          int pageRowCount = this.dataProvider.getPageRowCount();
  692.          int lastY = 0;
  693.          RECT testRect = new RECT();
  694.          int dc = pe.graphics.getHandle();
  695.          testRect.left = inside.x;
  696.          testRect.right = inside.x + inside.width;
  697.  
  698.          for(int displayIndex = 0; displayIndex < pageRowCount; ++displayIndex) {
  699.             Rectangle rowBounds = this.getRowBounds(displayIndex);
  700.             testRect.top = rowBounds.y;
  701.             testRect.bottom = rowBounds.y + rowBounds.height;
  702.             if (Windows.RectVisible(dc, testRect)) {
  703.                StringDisplayer displayer = this.stringDisplayer;
  704.                if (DataProvider.rowsEqual(this.selectedRow, this.dataProvider.getDisplayRow(displayIndex))) {
  705.                   displayer = this.stringSelectedDisplayer;
  706.                } else if (DataProvider.rowsEqual(this.hotTrack, this.dataProvider.getDisplayRow(displayIndex))) {
  707.                   this.stringDisplayer.setForeColor(Color.HOTTRACK);
  708.                }
  709.  
  710.                displayer.paintIn(pe.graphics, rowBounds, pe.clipRect, this.getDisplayData(displayIndex));
  711.                this.stringDisplayer.setForeColor((Color)null);
  712.             }
  713.  
  714.             lastY = rowBounds.y + rowBounds.height;
  715.          }
  716.  
  717.          if (lastY < inside.y + inside.height) {
  718.             pe.graphics.setPen((Pen)null);
  719.             pe.graphics.drawRect(inside.x, lastY, inside.width, inside.height - lastY + this.borderDisplayer.getBorderHeight());
  720.          }
  721.  
  722.       } else {
  723.          this.onNoRowsetPaint(pe);
  724.       }
  725.    }
  726.  
  727.    public String getListColumn() {
  728.       return this.listColumn;
  729.    }
  730. }
  731.